package com.ybf.api.mapper.provider;

import com.ybf.api.entity.User;
import org.apache.ibatis.annotations.Param;

public class UserProvider {
    public StringBuilder findAll(@Param("user") User user) {
        StringBuilder sql = new StringBuilder("select username, phone, img, sex, intro, status, updated_at, created_at, id, nickname from users where 1 = 1");
        if(user.getUsername() != null) {
            sql.append(" and username = #{user.username}");
        }
        if(user.getPhone() != null) {
            sql.append(" and phone = #{user.phone}");
        }
        if(user.getStatus() != null) {
            sql.append(" and status = #{user.status}");
        }
        return sql;
    }
}
